﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TorchView.GameContent.Data;
using System.ComponentModel;

namespace TorchView.GameContent.Skills
{
  public sealed class SkillEffects : IDataSerializable
  {
    public const string BLOCK_NAME = "EFFECTS";

    public void LoadFromDataBlock(DataBlock block)
    {
      if (block == null)
        throw new ArgumentNullException("block");
      if (block.Name != BLOCK_NAME)
        throw new ArgumentException("Incorrect block type, only " + BLOCK_NAME + " is supported.");
      Data = block;
      Target = block.GetPropertyValue("TARGET", string.Empty);
      TargetType = block.GetPropertyValue("TARGETTYPE", string.Empty);
    }

    public DataBlock MakeDataBlock()
    {
      var block = Data == null ? new DataBlock(BLOCK_NAME) : Data;
      block.SetPropertyValue("TARGET", Target);
      block.SetPropertyValue("TARGETTYPE", TargetType);
      return block;
    }

    public DataBlock Data { get; set; }

    [DisplayName("Effects"), Description("Effects"), Category("EFFECTS")]
    public string Effects { get; set; }

    [Description("Target for Effects"), Category("EFFECTS"), DisplayName("Target Type")]
    public string Target { get; set; }

    [Description("UnitType for Effects"), Category("EFFECTS"), DisplayName("UnitType")]
    public string TargetType { get; set; }

    public override string ToString()
    {
      return BLOCK_NAME;
    }
  }
}
